import java.io.*;
import java.util.*;
import java.net.*;

public class ConnectionWithHttp extends Thread{

	private static ArrayList<String> ulrs;
	private int startIndex;
	private int endIndex;
	private ArrayList<HttpURLConnection> cons;
	public ConnectionWithHttp (ArrayList<String> a, int start, int end){
		ulrs = a;
		startIndex = start;
		endIndex = end;
		cons = new ArrayList<HttpURLConnection>();
	}
	public void run(){
		try {
			for (int i = startIndex; i < endIndex; i++){
				URL myURL = new URL(ulrs.get(i));
				HttpURLConnection myURLConnection = (HttpURLConnection) myURL.openConnection();
				
				myURLConnection.connect();
		//		cons.add(myURLConnection);
		//		System.out.println(myURLConnection.getResponseCode());
			}
		//    System.out.println("DONE");
		} 
		catch (MalformedURLException e) { 
		    // new URL() failed
		    e.printStackTrace();
		} 
		catch (IOException e) {   
		    // openConnection() failed
		    e.printStackTrace();
		}
	}
	
	public void disConnectAll(){
		for(HttpURLConnection con : cons){
			con.disconnect();
		}
	}
}
